#set( $symbol_pound = '#' )
#set( $symbol_dollar = '$' )
#set( $symbol_escape = '\' )
package ${package}.server.service;

import java.io.IOException;

import oauth.signpost.OAuthConsumer;
import oauth.signpost.exception.OAuthCommunicationException;
import oauth.signpost.exception.OAuthExpectationFailedException;
import oauth.signpost.exception.OAuthMessageSignerException;

import org.apache.http.HttpResponse;
import org.apache.http.client.ClientProtocolException;
import org.apache.http.client.HttpClient;
import org.apache.http.client.methods.HttpPost;
import org.apache.http.entity.StringEntity;
import org.apache.http.impl.client.DefaultHttpClient;
import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;

public class YahooService {

	public static JSONObject getData(OAuthConsumer consumer,JSONArray jsonObjSend) throws OAuthMessageSignerException, OAuthExpectationFailedException, OAuthCommunicationException, ClientProtocolException, IOException, IllegalStateException, JSONException{
		  //Create a HTTP Post request
        
        HttpPost request = new HttpPost("http://mail.${artifactId}apis.com/ws/mail/v1.1/jsonrpc");
        request.addHeader("Content-type", "application/json");
        request.addHeader("Accept", "application/json");
        StringEntity se;
        se = new StringEntity(jsonObjSend.toString());
        request.setEntity(se);
        //Sign the request 
        consumer.sign(request);
        //Constructing an Http Client
        HttpClient httpClient = new DefaultHttpClient();
        HttpResponse response = httpClient.execute(request);
        // JSON object to hold the information, which is sent to the server
        JSONObject jsonObjRecv = ReadResponse.parseResponse(response);
        return jsonObjRecv;
	}
}
